<template>
	<view class="search-selector" v-if="show">
		<view class="ss-header flex-col-between">
			<view class="">
				支行搜索
			</view>
			<view class="search-close" @click="close()">关闭</view>
		</view>
		<view class="search-container">
			<view class="search-bar">
				<input class="search-input"  placeholder-class="search-input-place" type="text" v-model="keywords" placeholder="输入支行关键字" @confirm="search" />
			</view>
			<view class="search-butt" @click="search">搜索</view>
		</view>
		<view class="search-list">
			<view class="option-item" v-for="item in options" :key="item[rangeValue]" @click="onSelect(item)">
				<view class="">
					{{item[rangeValue]}}
				</view>
				<view class="">
					{{item[rangeText]}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			rangeValue: {
				type: String,
				default: () => {
					return 'branch_code'
				}
			},
			rangeText: {
				type: String,
				default: () => {
					return 'branch_name'
				}
			},
			options: Array,
			onChange: Function,
			onSearch: Function
		},
		data() {
			return {
				imgBaseUrl: this.$config.imgBaseUrl,
				keywords: '',
				show:false
			}
		},
		methods: {
			onSelect(data) {
				this.$emit('onChange', data)
			},
			search() {
				this.$emit('onSearch', this.keywords)
			},
			open() {
				this.show = true;
			},
			close() {
				this.show = false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.search-selector {
		position: fixed;
		top: 148rpx;
		left: 0;
		background-color: #fff;
		height: calc(100vh - 148rpx);
		z-index: 199;
		padding: 30rpx;
		.ss-header {
			width: 100%;
			padding-bottom: 32rpx;
			text-align: right;
		}
		.search-close {
			color: #FF0036;
			padding-right: 15rpx;
		}

		.search-container {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.search-bar {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				width: 565rpx;
				height: 60rpx;
				padding: 0 30rpx;
				background: #F5F5F5;
				border-radius: 28rpx;
				.search-icon {
					width: 32rpx;
					height: 32rpx;
				}
				
				.search-input,.search-input-place {
					font-size: 28rpx;
					color: #323232;
					line-height: 60rpx;
				}
				.search-input {
					height: 60rpx;
				}
			}
			

			.search-butt {
				margin-left: 20rpx;
				width: 80rpx;
				font-size: 28rpx;
				font-weight: 600;
				color: #323232;
				line-height: 28rpx;
			}
		}
		.search-list {
			margin-top: 32rpx;
			height: calc(100% - 124rpx);
			overflow-y: scroll;
		}

		.option-item {
			padding: 40rpx 0;
			font-size: 28rpx;
			color: #323232;
			line-height: 28rpx;
			border-bottom: 1rpx solid #ebebeb;

			&:last-child {
				border-bottom: none;
			}
		}
	}
</style>
